crmForm.all.ca_status.ForceSubmit = true;

//=====================================================================================
// Iteration 3 - QualityAnd Risk
//=====================================================================================

SaveRegardingQualityAndRiskRecord();

function SaveRegardingQualityAndRiskRecord()
{
	if (document.frames("IFRAME_QualityAndRisk").crmForm != "undefined"
		&& document.frames("IFRAME_QualityAndRisk").crmForm != null
		&& document.frames("IFRAME_QualityAndRisk").CustomIsDirty != "undefined" 
		&& document.frames("IFRAME_QualityAndRisk").CustomIsDirty == true)
	{
		if (typeof (document.frames("IFRAME_QualityAndRisk").crmForm.all.ca_projectid.DataValue) != "undefined"
			&& document.frames("IFRAME_QualityAndRisk").crmForm.all.ca_projectid.DataValue == null)
		{
			var aProjectLookupData = new Array();
			var aProjectLookupItem = new Object();
			aProjectLookupItem.id = crmForm.ObjectId;
			aProjectLookupItem.typename = crmForm.ObjectTypeName;
			aProjectLookupItem.name = "Project";
			aProjectLookupData[0] = aProjectLookupItem;
			document.frames("IFRAME_QualityAndRisk").crmForm.all.ca_projectid.DataValue = aProjectLookupData;
			document.frames("IFRAME_QualityAndRisk").crmForm.all.ca_projectid.ForceSubmit = true;
			if (document.frames("IFRAME_QualityAndRisk").crmForm.IsDirty)
			{
				document.frames("IFRAME_QualityAndRisk").crmForm.all.ca_relatedmonitoringassessmentid.DataValue = null;
				document.frames("IFRAME_QualityAndRisk").crmForm.all.ca_relatedmonitoringassessmentid.ForceSubmit = true;
			}
		}
	
		var bSaveResult = document.frames("IFRAME_QualityAndRisk").crmForm.Save();
	}

	if (document.frames("IFRAME_MonitoringAndAssessment").crmForm != "undefined"
		&& document.frames("IFRAME_MonitoringAndAssessment").crmForm != null
		&& document.frames("IFRAME_MonitoringAndAssessment").CustomIsDirty != "undefined" 
		&& document.frames("IFRAME_MonitoringAndAssessment").CustomIsDirty == true)
	{
		if (typeof (document.frames("IFRAME_MonitoringAndAssessment").crmForm.all.ca_projectid.DataValue) != "undefined" 
			&& document.frames("IFRAME_MonitoringAndAssessment").crmForm.all.ca_projectid.DataValue == null)
		{
			var aProjectLookupData = new Array();
			var aProjectLookupItem = new Object();
			aProjectLookupItem.id = crmForm.ObjectId;
			aProjectLookupItem.typename = crmForm.ObjectTypeName;
			aProjectLookupItem.name = "Project";
			aProjectLookupData[0] = aProjectLookupItem;
			document.frames("IFRAME_MonitoringAndAssessment").crmForm.all.ca_projectid.DataValue = aProjectLookupData;
			document.frames("IFRAME_MonitoringAndAssessment").crmForm.all.ca_projectid.ForceSubmit = true;
		}

		var bSaveResult = document.frames("IFRAME_MonitoringAndAssessment").crmForm.Save();
	}
}
//=====================================================================================
